<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include/template::header"></th:block>

	<link rel="stylesheet" href="../../static/css/wechat.css" th:href="@{/css/wechat.css?v=20180703}">
	<title>微信支付_时事一点通</title>
</head>
<body>
	<div class="wrapper">
		<div class="wechat-header">
			<div class="container">
				<h3>微信支付</h3>
				<div class="wechat-header-info">
					<p>请使用微信扫一扫支付</p>
					<p>请长按识别二维码进行支付</p>
				</div>
			</div>
			<div class="wechat-pay-mod">
				<div class="wechat-pay-QRcode" id="wxPayQRCode"></div>
				<div class="wechat-pay-price">￥<em th:text="${money}">999</em></div>
			</div>
		</div>
	</div>
	<div class="pay-ok-mod" style="display: none;">
		<div class="pay-ok-header">
			<h3>支付成功</h3>
			<!-- <p>您已成功开通VIP，有效期至2018-09-09</p> -->
			<span class="ok-icon"></span>
		</div>
		<div class="pay-ok-container">
			<form class="form-horizontal pay-ok-form" onsubmit="return false;">
				<div class="form-group">
	                <div class="col-sm-12">
	                    <a class="btn btn-primary btn-block btn-radius" target="_blank" href="http://a.app.qq.com/o/simple.jsp?pkgname=com.huashitong.ssydt">去APP开始刷题吧</a>
	                </div>
	            </div>
	            <div class="form-group">
	                <div class="col-sm-12">
	                    <a href="/money/vip/myaccount" class="btn btn-line btn-block btn-radius" id="pay-ok-btn" >返回</a>
	                </div>
	            </div>
	        </form>
		</div>
	</div>
	<th:block th:include="include/template::js"></th:block>
	<script src="../../static/js/lib/qrcode.min.js" th:src="@{/js/lib/qrcode.min.js}"></script>
	<script th:inline="javascript">
		/*<![CDATA[*/
			var ty_codeUrl = /*[[${code_url}]]*/ 'codeurl';
			var ty_orderId = /*[[${orderId}]]*/ 'orderId';
		/*]]>*/
	</script>
	<script>
		var qrcode = new QRCode(document.getElementById("wxPayQRCode"), {
		    text: ty_codeUrl,
		    width: 190,
		    height: 190
		});
		// console.log(ty_codeUrl);
		if(device.isWX()) {
			$('.wechat-header-info p').eq(1).show();
		}else {
			$('.wechat-header-info p').eq(0).show();
		}
		window.setInterval(function(){ 
			$.ajax({
				type: 'post',
				url: '/money/order/state/' + ty_orderId + '/orderId',
				dataType: 'json',
				success: function(datas) {
					if(datas.code == '200'){
						// toastr.success("支付成功");
						var _url = '';
						var _urlFrom = tools.getuUrlQuery('from');
						if(_urlFrom == 'vip'){
							_url = '/money/vip/myaccount';
						}
						$('#pay-ok-btn').attr('href', _url);
						$('.pay-ok-mod').show(200);
					}
				}
			});
		}, 2000);
	</script>
</body>
</html>